package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.entity.Mycoupon;
import com.example.mapper.MycouponMapper;
import com.example.service.IMycouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kk
 * @since 2024-07-02
 */
@Service
public class MycouponServiceImpl extends ServiceImpl<MycouponMapper, Mycoupon> implements IMycouponService {
    @Autowired
    private MycouponMapper mapper;
    @Override
    public List<Mycoupon> getByCustomerId(Integer customerId){
        QueryWrapper<Mycoupon> wrapper=new QueryWrapper<>();
        wrapper.eq("customer_id",customerId);
        wrapper.orderByAsc("mycoupon_status").orderByDesc("mycoupon_create_time");
        List<Mycoupon> mycouponList=mapper.selectList(wrapper);
        return mycouponList;
    }

    @Override
    public List<Mycoupon> getByStatus(Integer customerId,Integer mycouponStatus){
        QueryWrapper<Mycoupon> wrapper = new QueryWrapper<>();
        wrapper.eq("customer_id",customerId);
        wrapper.eq("mycoupon_status",mycouponStatus);
        wrapper.orderByDesc("mycoupon_create_time");
        List<Mycoupon> mycouponList=mapper.selectList(wrapper);
        return mycouponList;
    }
}
